﻿using HECore.SerilogWebApi.Extensions;

namespace HECore.SerilogWebApi
{
    public class Startup
    {
        public IConfiguration Configuration { get; }
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public void ConfigureServices(IServiceCollection services)
        {
            // 使用Serilog记录日志
            services.AddConfigSerilog(configuration: Configuration);

            services.AddControllers();
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            // 使用Serilog记录请求日志
            app.UseSerilogRequestLogging();

            app.UseRouting();
            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
    }
}
